﻿namespace MSSqlSchemaDoc.Core.DataStructures
{
    using System;
    using System.Collections.ObjectModel;
    using System.Xml.Serialization;

    /// <summary>
    /// Represents a table.
    /// </summary>
    [Serializable()]
    public class Table : DataStructureObjectBase, IIndexableDataObject
    {
        /// <summary>
        /// Gets the table object type string.
        /// </summary>
        public override DataStructureObjectType ObjectType
        {
            get
            {
                return DataStructureObjectType.Table;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether the table uses ANSI_NULLS.
        /// </summary>
        [XmlElement()]
        public bool UsesAnsiNulls { get; set; }

        /// <summary>
        /// Gets or sets the columns of the table.
        /// </summary>
        [XmlArray()]
        public Collection<Column> Columns { get; set; }

        /// <summary>
        /// Gets or sets the triggers of the table.
        /// </summary>
        [XmlArray()]
        [XmlArrayItem("Trigger")]
        public Collection<TableTrigger> Triggers { get; set; }

        /// <summary>
        /// Gets or sets the indexes of the table.
        /// </summary>
        [XmlArray()]
        public Collection<Index> Indexes { get; set; }

        /// <summary>
        /// Gets or sets a collection of foreign key constraints.
        /// </summary>
        [XmlArray()]
        public Collection<ForeignKey> ForeignKeys { get; set; }
    }
}
